package gvo.basicDatatypes;

import gvo.presets.Presets;

public class StichwortDat {
	private int idStichwort;
	private String stichwort;
	public boolean isVerified = false;
	public boolean isInDB = false;
	
	public static final String XMLNAME = "StichwortDat";
	public static final String[] Titel={"idStichwort","stichwort"};
	public static final int IDSTICHWORT = 0;
	public static final int STICHWORT = 1;
	
	public StichwortDat(){
		this.idStichwort = Presets.NOID;
		this.stichwort = Presets.EMPTYTXT;
	}
	public StichwortDat(String stichwort){
		this.idStichwort = Presets.NOID;
		this.stichwort = stichwort;
	}
	public StichwortDat(int idStichwort, String stichwort,boolean isVerified,boolean isInDB){
		this.idStichwort = idStichwort;
		this.stichwort = stichwort;
		this.isVerified = isVerified;
		this.isInDB = isInDB;
	}
	public String info(){
		return String.format("STICHWORTDAT %5d | %10.10s ", 
				idStichwort, stichwort);
	}
	public static String infoTitel(){
		return String.format("STICHWORT    %5.5s | %10.10s ", (Object[])Titel);
	}
	public int getIdStichwort() {
		return idStichwort;
	}
	public void setIdStichwort(int idStichwort) {
		this.idStichwort = idStichwort;
	}
	public String getStichwort() {
		return stichwort;
	}
	public void setStichwort(String stichwort) {
		this.stichwort = stichwort;
	}

	public String prepStichwort() {

		if (stichwort == null) {
			return "<leeres Stichwort>";
		}
		if (stichwort.equals(Presets.EMPTYTXT)) {
			return  "<leeres Stichwort>";
		}

		if (stichwort.length() > Presets.MAXLENGTH) {
			return stichwort.substring(0, Presets.MAXLENGTH);
		}

		return stichwort;
	}
	public boolean equals(Object object) {
        if (!(object instanceof StichwortDat)) {
            return false;
        }
        StichwortDat other = (StichwortDat) object;
        if (this.idStichwort== Presets.NOID){
     	   return false;
        }
        if(this.idStichwort == other.idStichwort){
     	   return true;
        }
        return false;
    }
	 @Override
	public int hashCode() {
			int hash = 7;
			hash = 31 * hash + idStichwort;
			hash = 31 * hash + (null == stichwort ? 0 : stichwort.hashCode());
			return hash;
	}
	public String toString(){
		return prepStichwort();
	}

}
